<html><head><title>DatabaseQuery</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">DatabaseQuery()</font></b></p>
<p><b>Syntax</b></p><blockquote>
Result = <font color="#006666"><b>DatabaseQuery</b></font>(#Database, Request$ [, Flags])</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Executes a SQL query on the given database. Only queries which doesn't change the database 
records are accepted ('SELECT' like queries). To performs database modification, use <a href="databaseupdate.html">DatabaseUpdate()</a>. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Database</i></td>
<td width="90%"> 
The database to use. 

</td></tr>
<tr><td><i>Request$</i></td>
<td> 
The SQL query to execute. 

</td></tr>
<tr><td><i>Flags (optional)</i></td>
<td> 
The flags to use. It can be one of the following value: 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Database_StaticCursor</font> : performs the query to access the result in a sequential manner. It's not possible to rewind 
                              with <a href="previousdatabaserow.html">PreviousDatabaseRow()</a> or <a href="firstdatabaserow.html">FirstDatabaseRow()</a> on some drivers, but it is the faster way to get the data (default).
  <font color="#924B72">#PB_Database_DynamicCursor</font>: performs the query to access the result in a random manner using <a href="previousdatabaserow.html">PreviousDatabaseRow()</a> or <a href="firstdatabaserow.html">FirstDatabaseRow()</a>. 
                              It can be slower, or even unsupported on some drivers.
</font></pre>

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

Returns nonzero if the query was successful or zero if it failed (due to a SQL error or a badly-formatted query). 

</blockquote><p><b>Remarks</b></p><blockquote>

If the query has succeeded then <a href="nextdatabaserow.html">NextDatabaseRow()</a> can be used to list returned records 
(see the example below). In the event of an error, the error text can be retrieved with 
<a href="databaseerror.html">DatabaseError()</a>. It is safe to use <a href="nextdatabaserow.html">NextDatabaseRow()</a> even if the request 
doesn't return any records. To get the number of columns returned by the query, use <a href="databasecolumns.html">DatabaseColumns()</a>. 
<br>
<br>
Once the query results aren't needed anymore, <a href="finishdatabasequery.html">FinishDatabaseQuery()</a> has to be called 
to release all the query resources. 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#006666">; First, connect to a database with an employee table</font>
  <font color="#006666">;</font>
  <b><font color="#006666">If</font></b> <font color="#006666">DatabaseQuery</font>(<font color="#924B72">#Database</font>, "SELECT * FROM employee") <font color="#006666">; Get all the records in the 'employee' table</font>
  
    <b><font color="#006666">While</font></b> <font color="#006666">NextDatabaseRow</font>(<font color="#924B72">#Database</font>) <font color="#006666">; Loop for each records</font>
      <b><font color="#006666">Debug</font></b> <font color="#006666">GetDatabaseString</font>(<font color="#924B72">#Database</font>, 0) <font color="#006666">; Display the content of the first field      </font>
    <b><font color="#006666">Wend</font></b>
  
<font color="#006666">    FinishDatabaseQuery</font>(<font color="#924B72">#Database</font>)
  <b><font color="#006666">EndIf</font></b>
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="databaseupdate.html">DatabaseUpdate()</a>, <a href="nextdatabaserow.html">NextDatabaseRow()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=databaseid.html>DatabaseID()</a> - <a href=index.html>Database Index</a> - <a href=databaseupdate.html>DatabaseUpdate()</a> ->

</body></html>